# while循环
i = 1
while i <= 5:
    print("Hello Python")
    i = i + 1
print("循环结束i=%d" % i)

# 赋值运算
# 计算0~100的和
count = 0
index = 0
while index <= 100:
    count += index
    index += 1
print("0~100的和为：%d" % count)

# 计算0~100所有偶数的和
evenIndex = 0
evenCount = 0
while evenIndex <= 100:
    if evenIndex % 2 == 0:
        evenCount += evenIndex
    evenIndex += 1
print("0~100所有偶数的和=%d" % evenCount)

# break
b = 0
while b <= 5:
    if b == 3:
        break
    print(b)
    b += 1

# continue
c = 0
while c <= 5:
    if c == 3:
        # 处理循环条件防止死循环
        c += 1
        continue
    print(c)
    c += 1

# 打印小星星
# 1.使用python提供的字符串乘法操作
print("python字符串乘法打印小星星")
starIndex = 1
while starIndex <= 5:
    print("*" * starIndex)
    starIndex += 1

# 2.使用循环嵌套
# 星星行数
print("while嵌套打印小星星")
starRowIndex = 1
# 星星列数
while starRowIndex <= 5:
    startColIndex = 1
    while startColIndex <= starRowIndex:
        print("*", end="")
        startColIndex += 1
    starRowIndex += 1
    print("")
